<!--  -->
<template>
  <div class='dwcs'>
      <van-nav-bar
      title="选择城市"
      :left-text="city"
      fixed
      @click-left="$router.back()"
    />
    <van-index-bar class="content" :sticky-offset-top="46" >
        <div v-for="(value,key) in cities" :key="key">
            <van-index-anchor :index="key" />
  <van-cell v-for="item in value" :key="item.id" :title="item.name" @click="selectcity(item.name)"/>
        </div>
  
  

  ...
</van-index-bar>
  </div>
</template>

<script>
import { huoqucshi } from "network/api.js";
import { mapState,mapMutations } from "vuex";
export default {
name:'',
  data () {
    return {
        cities:{}
    };
  },


  computed: {
      ...mapState(["city"])
  },


  methods: {
      ...mapMutations(["xzcs"]),
      async huoqucshilist(){
          const {data,errcode,errmsg}=await huoqucshi()
          if(errcode!=0) return this.$toast(errmsg)
          this.cities=data.cities
          console.log(this.cities)
          
      },
      selectcity(a){
          this.xzcs(a)
          this.$router.push('/home')
      }
  },
  created(){
      this.huoqucshilist()
  }
}

</script>
<style lang='less' scoped>
.content{
    margin-top: 46px;
}
</style>